﻿Public Class RcomoSeEntero

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EcomoSeEntero)
        Dim seEnteros As List(Of EcomoSeEntero) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                seEnteros = DcomoSeEntero.SeleccionarTodo(descEmpresa)
                If seEnteros Is Nothing Then seEnteros = New List(Of EcomoSeEntero)
                If DisplaySelect Then seEnteros.Insert(0, New EcomoSeEntero("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return seEnteros
    End Function
    Public Shared Function SeleccionarXEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of EcomoSeEntero)
        Dim seEnteros As List(Of EcomoSeEntero) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                seEnteros = DcomoSeEntero.SeleccionarXEstado(descEmpresa)
                If seEnteros Is Nothing Then seEnteros = New List(Of EcomoSeEntero)
                If DisplaySelect Then seEnteros.Insert(0, New EcomoSeEntero("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return seEnteros
    End Function
    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pSeEntero As EcomoSeEntero) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DcomoSeEntero.Añadir(descEmpresa, pSeEntero)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pSeEntero As EcomoSeEntero) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DcomoSeEntero.Editar(descEmpresa, pSeEntero)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pSeEntero As EcomoSeEntero) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = DcomoSeEntero.Eliminar(descEmpresa, pSeEntero)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    '******* RptGerenciales xComoSeEntero  *******'
    Public Shared Function rptGerenciales_xComoSeEntero(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal rptGerencial As EproformaCabecera) As List(Of EcomoSeEntero)
        Dim comoSeEnteros As List(Of EcomoSeEntero) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                comoSeEnteros = DcomoSeEntero.rptGerenciales_xComoSeEntero(descEmpresa, rptGerencial)
                If comoSeEnteros Is Nothing Then comoSeEnteros = New List(Of EcomoSeEntero)
                'If DisplaySelect Then accions.Insert(0, New xOperaciones("00", "-- SELECIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return comoSeEnteros
    End Function

End Class
